getProvidersRatings
getProvidersRatings
This method retrieves a list of ratings for all providers (agents), optionally including recent user comments.
-
Retrieve Providers with Ratings
-
Query the
rating_providertable for all providers who have:- An associated agent
- Their overall rating and count data
-
If no providers are found, return an empty array (end of process).
-
-
(Optional) Fetch Comments
- Triggered only if
includeCommentsistrue. - Extract a list of agent IDs from the retrieved providers.
- Fetch recent comments for these agents, constrained by the optional
limit.
- Triggered only if
-
Build Provider Ratings Response
-
For each provider:
-
Create a response object with:
- Agent ID
- Average Rating
- Overall Rating Count
-
(If applicable), filter the fetched comments to only include those for this agent and attach them to the response.
-
-
-
Return Final List
- Return an array of all provider rating responses.
- Each response may optionally include user comments.